package com.qymerge.manage.core.third.wechat.dto.menu;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * Desc
 * User licong
 * Date 2016/6/23
 * Time 16:41
 */
@Data
public class MenuButtonItemDTO implements Comparable<MenuButtonItemDTO>, Serializable{

    private String type;    //菜单的响应动作类型
    private String name;    //菜单标题，不超过16个字节，子菜单不超过40个字节
    private String key;     //菜单KEY值，用于消息接口推送，不超过128字节
    private String url;     //网页链接，用户点击菜单可打开链接，不超过1024字节
    private List<MenuButtonItemDTO> sub_button; //二级菜单数组，个数应为1~5个

    private String v_id;    //虚拟ID,微信接口里没有
    private int m_sort;     //排序字段

    public MenuButtonItemDTO(){}

    public MenuButtonItemDTO(String type, String name, String key, String url) {
        this.type = type;
        this.name = name;
        if ("view".equals(type)){
            this.url = url;
        } else if ("click".equals(type)){
            this.key = key;
        }
    }

    @Override
    public int compareTo(MenuButtonItemDTO o) {
        if (this.m_sort > o.getM_sort()){
            return 1;
        }else{
            return -1;
        }
    }
}
